package event;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class ActionEventEx1 implements ActionListener {

	JButton s = new JButton("남쪽");
	JButton n = new JButton("북쪽");
	JButton e = new JButton("동쪽");
	JButton w = new JButton("서쪽");
	JButton c = new JButton("중앙");

	public ActionEventEx1() {
		JFrame f = new JFrame("이벤트 테스트1");
		f.setBounds(100, 100, 300, 200);
		f.setVisible(true);

		f.add(s, BorderLayout.SOUTH);
		f.add(n, BorderLayout.NORTH);
		f.add(e, BorderLayout.EAST);
		f.add(w, BorderLayout.WEST);
		f.add(c, BorderLayout.CENTER);

		s.addActionListener(this);
		n.addActionListener(this);
		e.addActionListener(this);
		w.addActionListener(this);
		c.addActionListener(this);

	}

	public static void main(String[] args) {
		new ActionEventEx1();

	}

	@Override
	public void actionPerformed(ActionEvent ev) {

		JButton obj = (JButton) ev.getSource(); // 이벤트가 발생한 그 무엇...

		if (ev.getSource() == s) {

		}
		System.out.println(obj.getText() + "이벤트 발생");
	}
}
